const http = require('http');
//引入url模块 处理request.url的路径及参数问题
const url = require('url');
const server = http.createServer((request, response)=>{
    // 先获取请求的url  request.url
    // http://127.0.0.1:8080/s?wd=jike001&bg=red
    console.log(request.url);//   /s?wd=jike001&bg=red
    // url.parse方法，可以将路径进行解析
    let urlObj = url.parse(request.url, true);
    // 请求路径 
    console.log('pathname',urlObj.pathname);
    // 请求的查询字符串参数 query对象里
    console.log('wd:',urlObj.query.wd);
    console.log('bg',urlObj.query.bg);
    // console.log(urlObj);
})

server.listen(8080,()=>{
    console.log('server run at 8080');
})